function getToken() {
    var arr = window.location.search.substring(1).split('&')
    console.log(arr)
    for (let item of arr) {
        let a = item.split('=')
        uni.setStorageSync(a[0], a[1])
    }
}
getToken()



/**
 *  HTTP 简单封装
 */
export default class Rest {
    /**
     * 构造方法
     */
    constructor() {
            /**
             * 接口基础地址
             * @type {string}
             */
            // this.baseURL = 'http://192.168.1.118:21100/gateway'
            this.baseURL = process.env.NODE_ENV == 'development' ? '/api/gateway' : '/gateway'
                // this.baseURL = '/gateway' 
                /**
                 * 请求路劲
                 * @type {string}
                 */
            this.path = ''
                /**
                 * Headers
                 * @type {Object}
                 */

            this.header = { "content-type": "application/x-www-form-urlencoded", Authorization: uni.getStorageSync('sessionId') }


            // 支持的请求方式
            const methods = ['GET', 'POST', 'PUT', 'DELETE']
                // 注册方法到 this
            methods.forEach((method) => {
                this[method] = options => this.request(method, options)
            })
        }
        /**
         * 请求
         * @param {string} method='GET' 请求方式
         * @param {Object} [options={}] 选项
         */
    request(method = 'GET', options = {}, header = this.header) {
        const { data = {}, url = '' } = options
        return new Promise((resolve, reject) => {
            uni.request({
                url: this.baseURL + url,
                data,
                method,
                header,
                success: function(res) {
                    if (res.statusCode === 200) {
                        resolve(res.data)
                    } else {
                        console.log(222)
                        reject()
                        uni.showToast({
                            title: res.data.msg,
                            icon: 'none'
                        });
                    }
                }
            })
        })
    }

    /**
     * 附加路劲
     * @param {string} [path=''] 路劲
     */
    addPath(path = '') {
        this.path = `${this.path}/${path}`

        return this
    }

    /**
     * 添加 Headers
     * @param {Object} headers Headers
     */
    addHeaders(headers) {
        Object.assign(this.headers, headers)
        return this
    }
}